using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace Match.TimingApplication.Forms
{
    public partial class frmDataExport : Form
    {
        public frmDataExport()
        {
            InitializeComponent();

            foreach (String Value in Environment.GetLogicalDrives())
            {
                comboBoxDrives.Items.Add(Value);
            }
            comboBoxDrives.SelectedIndex = 0;
        }

        private void buttonStartExport_Click(object sender, EventArgs e)
        {
            try
            {
                Directory.CreateDirectory(comboBoxDrives.SelectedItem.ToString() + @"Archive\");
                if(File.Exists(Application.StartupPath + @"\Archive\RegistredRaceStarts.csv"))
                    File.Copy(Application.StartupPath + @"\Archive\RegistredRaceStarts.csv", comboBoxDrives.SelectedItem + "RegistredRaceStarts.csv",true);
                if (File.Exists(Application.StartupPath + @"\Archive\RegistredParticipantTimes.csv"))
                    File.Copy(Application.StartupPath + @"\Archive\RegistredParticipantTimes.csv", comboBoxDrives.SelectedItem + "RegistredParticipantTimes.csv",true);
                MessageBox.Show("Datenxport beendet");
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}